home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / PowerMacInterface / events.icl < prev    next >
Encoding:
Modula Implementation  |  1997-06-13  |  3.6 KB  |  143 lines  |  [TEXT/3PRM]

  1. implementation module events;
  2.  
  3. import mac_types;
  4. import StdInt;
  5.  
  6. //    Event masks
  7.  
  8. MDownMask    :== 2;
  9. MUpMask     :== 4;
  10. KeyDownMask :== 8;
  11. KeyUpMask    :== 16;
  12. AutoKeyMask :== 2;
  13. UpdateMask    :== 64;
  14. DiskMask    :== 128;
  15. ActivMask    :== 256;
  16. NetworkMask :== 1024;
  17. DriverMask    :== 2048;
  18. OsMask        :== -32768;
  19.  
  20. //    Device masks
  21.  
  22. MouseMask        :== 6;        // MouseDown | MouseUp
  23. KeyboardMask    :== 56;        // KeyDown     | KeyUp | AutoKey
  24.  
  25. //    Event codes
  26.  
  27. NullEvent        :== 0;
  28. MouseDownEvent    :== 1;
  29. MouseUpEvent    :== 2;
  30. KeyDownEvent    :== 3;
  31. KeyUpEvent        :== 4;
  32. AutoKeyEvent    :== 5;
  33. UpdateEvent     :== 6;
  34. DiskEvent        :== 7;
  35. ActivateEvent    :== 8;
  36. NetworkEvent    :== 10;
  37. DriverEvent     :== 11;
  38. OsEvent            :== 15;
  39. HighLevelEvent :== 23;
  40.  
  41. //    Flags for suspend and resume events
  42.  
  43. ResumeFlag                :== 1;
  44. ConvertClipboardFlag    :== 2;
  45.  
  46. //    Message codes for operating-system events
  47.  
  48. SuspendResumeMessage    :== 1;        // $01
  49. MouseMovedMessage        :== 250;    // $FA
  50.  
  51. GetNextEvent :: !Int !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int,!Int,!Toolbox);
  52. GetNextEvent eventMask t
  53. =    (b,what,message,when,(position<<16)>>16,position>>16,modifiers,0);
  54. {
  55.     (b,what,message,when,position,modifiers)= GetNextEvent2 eventMask t;
  56. }
  57.  
  58. GetNextEvent2 :: !Int !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int);
  59. GetNextEvent2 eventMask t
  60. = code (eventMask=R16D0,t=O0D1U)(b=D0,what=W,message=L,when=L,position=L,modifiers=W){
  61.     call    .GetNextEvent
  62.     instruction    0x70630001    |    andi.    r3,r3,1
  63.     instruction    0x7C6300D0    |    neg        r3,r3
  64. };
  65.  
  66. EventAvail :: !Int !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int,!Int,!Toolbox);
  67. EventAvail eventMask t
  68. =    (b,what,message,when,(position<<16)>>16,position>>16,modifiers,0);
  69. {
  70.     (b,what,message,when,position,modifiers)= EventAvail2 eventMask t;
  71. }
  72.  
  73. EventAvail2 :: !Int !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int);
  74. EventAvail2 eventMask t = code (eventMask=R16D0,t=O0D1U)(b=D0,what=W,message=L,when=L,position=L,modifiers=W){
  75.     call    .EventAvail
  76.     instruction    0x70630001    |    andi.    r3,r3,1
  77.     instruction    0x7C6300D0    |    neg        r3,r3
  78. };
  79.  
  80. WaitNextEvent :: !Int !Int !RgnHandle !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int,!Int,!Toolbox);
  81. WaitNextEvent eventMask sleep mouseRgn t
  82. =    (b,what,message,when,(position<<16)>>16,position>>16,modifiers,0);
  83. {
  84.     (b,what,message,when,position,modifiers)= WaitNextEvent2 eventMask sleep mouseRgn t;
  85. }
  86.  
  87. WaitNextEvent2 :: !Int !Int !RgnHandle !Toolbox -> (!Bool,!Int,!Int,!Int,!Int,!Int);
  88. WaitNextEvent2 eventMask sleep mouseRgn t
  89. = code (eventMask=R16D0,sleep=O0D1D2,mouseRgn=D3,t=U)(b=D0,what=W,message=L,when=L,position=L,modifiers=W){
  90.     call    .WaitNextEvent
  91.     instruction    0x70630001    |    andi.    r3,r3,1
  92.     instruction    0x7C6300D0    |    neg        r3,r3
  93. };
  94.  
  95. TickCount :: !Toolbox -> (!Int,!Toolbox);
  96. TickCount t = code (t=U)(r=D0,z=Z){
  97.     call    .TickCount
  98. };
  99.  
  100. GetMouse :: !Toolbox -> (!Int,!Int,!Toolbox);
  101. GetMouse tb
  102. =    (h,v,tb1);
  103.     where {
  104.         (v,h,tb1) =: GetMouse1 tb;
  105.     };
  106.     
  107. GetMouse1 :: !Toolbox -> (!Int,!Int,!Toolbox);
  108. GetMouse1 t = code (t=R4O0D0U)(v=W,h=W,z=Z){
  109.     call    .GetMouse
  110. };
  111.  
  112. Button :: !Toolbox -> (!Bool,!Toolbox);
  113. Button t = code (t=U)(b=D0,z=Z){
  114.     call    .Button
  115.     instruction    0x70630001    |    andi.    r3,r3,1
  116.     instruction    0x7C6300D0    |    neg        r3,r3
  117. };
  118.  
  119. StillDown :: !Toolbox -> (!Bool,!Toolbox);
  120. StillDown t = code (t=U)(b=D0,z=Z){
  121.     call    .StillDown
  122.     instruction    0x70630001    |    andi.    r3,r3,1
  123.     instruction    0x7C6300D0    |    neg        r3,r3
  124. };
  125.  
  126. WaitMouseUp :: !Toolbox -> (!Bool,!Toolbox);
  127. WaitMouseUp t = code (t=U)(b=D0,z=Z){
  128.     call    .WaitMouseUp
  129.     instruction    0x70630001    |    andi.    r3,r3,1
  130.     instruction    0x7C6300D0    |    neg        r3,r3
  131. };
  132.  
  133. GetKeys :: !Toolbox -> (!Int,!Int,!Int,!Int,!Toolbox);
  134. GetKeys t = code (t=R16O0D0U)(k0=L,k1=L,k2=L,k3=L,z=Z){
  135.     call    .GetKeys
  136. };
  137.  
  138. HasWaitNextEvent :: !Toolbox -> (!Bool,!Toolbox);
  139. HasWaitNextEvent tb = (True, NewToolbox);
  140.  
  141. HasWaitNextEvent1 :: !Toolbox -> Bool;
  142. HasWaitNextEvent1 t = True;
  143.